package LC;

import java.util.LinkedList;

public class LC513 {
    public static int findBottomLeftValue(TreeNode root) {
        if (root==null) return 0;
        LinkedList<TreeNode> treeNodes = new LinkedList<>();
        treeNodes.add(root);
        int a = 0;
        while (treeNodes.size()!=0){
            int size = treeNodes.size();
            a = treeNodes.getFirst().val;
            for (int i = 0; i < size; i++) {
                TreeNode pop = treeNodes.pop();
                if(pop.left!=null){
                    treeNodes.add(pop.left);
                }
                if(pop.right!=null){
                    treeNodes.add(pop.right);
                }
            }
        }
        return a;
    }

    public static void main(String[] args) {
        TreeNode treeNode = new TreeNode(10);
        int bottomLeftValue = findBottomLeftValue(treeNode);
    }
}
